<?php

/**
 * This is the model class for table "{{contact}}".
 *
 * The followings are the available columns in table '{{contact}}':
 * @property integer $id
 * @property integer $student_id
 * @property string $father_mobile_no
 * @property string $mother_mobile_no
 * @property string $home_fixed_no
 * @property string $mother_office_no
 * @property string $father_office_no
 * @property string $emergency_contact_no
 * @property string $mother_email
 * @property string $father_email
 * @property string $created_date
 * @property string $updated
 * @property integer $deleted
 */
class Contact extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Contact the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{contact}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('student_id', 'required'),
			array('student_id, deleted', 'numerical', 'integerOnly'=>true),
			array('father_mobile_no, mother_mobile_no, home_fixed_no, mother_office_no, father_office_no, emergency_contact_no', 'length', 'max'=>15),
			array('mother_email, father_email', 'length', 'max'=>150),
			array('created_date, updated', 'safe'),
			array('created_date','default','value'=>new CDbExpression('NOW()'),'setOnEmpty'=>false,'on'=>'insert'),
			array('updated','default','value'=>new CDbExpression('NOW()'),'setOnEmpty'=>false,'on'=>'update'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, student_id, father_mobile_no, mother_mobile_no, home_fixed_no, mother_office_no, father_office_no, emergency_contact_no, mother_email, father_email, created_date, updated, deleted', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'student_id' => 'Student',
			'father_mobile_no' => 'Father Mobile No',
			'mother_mobile_no' => 'Mother Mobile No',
			'home_fixed_no' => 'Home Fixed No',
			'mother_office_no' => 'Mother Office No',
			'father_office_no' => 'Father Office No',
			'emergency_contact_no' => 'Emergency Contact No',
			'mother_email' => 'Mother Email',
			'father_email' => 'Father Email',
			'created_date' => 'Created Date',
			'updated' => 'Updated',
			'deleted' => 'Deleted',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('student_id',$this->student_id);
		$criteria->compare('father_mobile_no',$this->father_mobile_no,true);
		$criteria->compare('mother_mobile_no',$this->mother_mobile_no,true);
		$criteria->compare('home_fixed_no',$this->home_fixed_no,true);
		$criteria->compare('mother_office_no',$this->mother_office_no,true);
		$criteria->compare('father_office_no',$this->father_office_no,true);
		$criteria->compare('emergency_contact_no',$this->emergency_contact_no,true);
		$criteria->compare('mother_email',$this->mother_email,true);
		$criteria->compare('father_email',$this->father_email,true);
		$criteria->compare('created_date',$this->created_date,true);
		$criteria->compare('updated',$this->updated,true);
		$criteria->compare('deleted',$this->deleted);

		return new CActiveDataProvider(get_class($this), array(
			'pagination'=>array(
    	   		'pageSize'=> ITEMS_PER_PAGE,
    		),
			'criteria'=>$criteria,
			
		));
	}
}